<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>

<link rel="stylesheet" href="js/easyui-1.3.0/themes/default/easyui.css" />
<link rel="stylesheet" href="js/easyui-1.3.0/themes/icon.css" />
<style type="text/css">
#editor { 
        margin: 0;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
    }
</style>
<script src="js/jquery/jquery-1.8.2.js"></script>
<script src="js/easyui-1.3.0/jquery.easyui.min.js"></script>
<script src="js/jquery/jquery.hotkeys.js"></script>
<script src="js/ace/ace.js"></script>
<script src="js/ace/htmlformat.js"></script>
<script src="js/ace/jsformat.js"></script>
<script type="text/javascript">
var editor = null;
$(function(){
	editor = ace.edit("editor");
	editor.setTheme("ace/theme/monokai");
	editor.getSession().setMode("ace/mode/"+$('#mode').val());
	editor.getSession().setValue($('#content').val());
	editor.focus();
	editor.on("change",function(){
		window.parent.onEditChange($('#filePath').val());
	});
	jQuery.hotkeys.add('Ctrl+S',function(){
		window.parent.onEditorSave($('#filePath').val());
		save();
	});
	
	jQuery.hotkeys.add('Ctrl+Shift+F',function(){
	    var html = style_html(editor.getSession().getValue());
	    editor.getSession().setValue(html);
	});
});
	

function save(){
	$('#content').val(editor.getValue());
	$('#saveFileLink').click();
}
function saveSuccess(){
}
</script>
</head>
<body scroll=no>

<form id="form" wicket:id="ajaxForm" style="display:none">
	<input type="text" id="filePath" name="filePath" wicket:id="filePath"></input>
	<input type="hidden" id="content"  wicket:id="content" />
	<input type="hidden" id="mode"  wicket:id="mode" />
	<a href="javascript:void(0)" class="easyui-linkbutton" id="saveFileLink" wicket:id="saveFileLink">ok</a>
</form>

<div id="editor"></div>

</body>
</html>